<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:fragment="head">
    <meta charset="UTF-8">
    <title>首页</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-table@1.22.3/dist/bootstrap-table.min.css" rel="stylesheet">

    <script src="https://cdn.staticfile.net/jquery/1.10.2/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.22.3/dist/bootstrap-table.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.22.3/dist/locale/bootstrap-table-zh-CN.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
    <link href="//cdn.staticfile.org/layui/2.9.7/css/layui.css" rel="stylesheet">
    <script src="//cdn.staticfile.org/layui/2.9.7/layui.js"></script>
    <style>
        /* 使右侧导航项靠右 */
        .layui-nav-right {
            float: right;
        }
    </style>
</head>

<body>
    <!-- 导航栏 -->
    <ul class="layui-nav" th:replace="index::nav">

    </ul>

    <div>
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-container">
                    <form class="layui-form" action="" lay-filter="testform">
                        <div class="layui-form-item">
                            <label class="layui-form-label">名字</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" value="" required lay-verify="required"
                                    placeholder="请输入名字" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别</label>
                            <div class="layui-input-block">
                                <input type="radio" name="gender" value="男" title="男">
                                <input type="radio" name="gender" value="女" title="女" checked>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">职位</label>
                            <div class="layui-input-block">
                                <input type="text" name="position" value="" required lay-verify="required"
                                    placeholder="请输入职位" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">电话</label>
                            <div class="layui-input-block">
                                <input type="text" name="phone" value="" required lay-verify="required"
                                    placeholder="请输入电话" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">地址</label>
                            <div class="layui-input-block">
                                <input type="text" name="address" value="" required lay-verify="required"
                                    placeholder="请输入地址" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">身份证</label>
                            <div class="layui-input-block">
                                <input type="text" name="idCard" value="" required lay-verify="required"
                                    placeholder="请输入身份证" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">入党日期</label>
                            <div class="layui-input-block">
                                <input type="text" name="inDate" id="inDate" value="" required lay-verify="required"
                                    placeholder="请输入入党日期" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    layui.use(['layer'], function (args) {
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        // 渲染
        laydate.render({
            elem: '#inDate'
        });
        form.on('submit(formDemo)', function (data) {
            // layer.msg(JSON.stringify(data.field));
            $.post('/pmember', data.field, function (data) {
                if (data.code === 200) {
                    layer.msg('新增ok!');
                    setTimeout(() => {
                        window.location.href = "/index";
                    }, 1200);
                }
            })
            return false;
        });
    });

</script>

</html>